package org.whuims.entity;

import org.apache.solr.client.solrj.beans.Field;
import org.springframework.data.solr.core.mapping.SolrDocument;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "std_std")
@SolrDocument(solrCoreName = "std_std")
public class Standard extends IdEntity {
    @Field(value = "name")
    private String name;
    @Field(value = "title_cn")
    private String titleCn;
    @Field(value = "title_en")
    private String titleEn;
    @Field(value = "cat_cn")
    private String catCn;
    @Field(value = "cat_ics")
    private String catIcs;
    @Field(value = "cat_std")
    private String catStd;
    @Field(value = "publish_date")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date publishDate;
    @Field(value = "effective_date")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date effectiveDate;
    @Field(value = "language")
    private String language;
    @Field(value = "qicao")
    private String qicao;
    @Field(value = "guikou")
    private String guikou;
    @Field(value = "reference")
    private String reference;
    @Field(value = "work_field")
    private String workField;
    @Field(value = "pdf_path")
    private String pdfPath;
    @Field(value = "txt_path")
    private String txtPath;
    private List<Standard> refStds;
    @Field(value = "text_ocr")
    private String textOcr;
    @Field(value = "valid")
    private Integer valid;
    @Field(value = "searchFields")
    private String searchFields;
    @Field(value = "quotas")
    private String quotas;

    public Integer getValid() {
        return valid;
    }

    public void setValid(Integer valid) {
        this.valid = valid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTitleCn() {
        return titleCn;
    }

    public void setTitleCn(String titleCn) {
        this.titleCn = titleCn;
    }

    public String getTitleEn() {
        return titleEn;
    }

    public void setTitleEn(String titleEn) {
        this.titleEn = titleEn;
    }

    public String getCatCn() {
        return catCn;
    }

    public void setCatCn(String catCn) {
        this.catCn = catCn;
    }

    public String getCatIcs() {
        return catIcs;
    }

    public void setCatIcs(String catIcs) {
        this.catIcs = catIcs;
    }

    public String getCatStd() {
        return catStd;
    }

    public void setCatStd(String catStd) {
        this.catStd = catStd;
    }

    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public Date getEffectiveDate() {
        return effectiveDate;
    }

    public void setEffectiveDate(Date effectiveDate) {
        this.effectiveDate = effectiveDate;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getQicao() {
        return qicao;
    }

    public void setQicao(String qicao) {
        this.qicao = qicao;
    }

    public String getGuikou() {
        return guikou;
    }

    public void setGuikou(String guikou) {
        this.guikou = guikou;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getWorkField() {
        return workField;
    }

    public void setWorkField(String workField) {
        this.workField = workField;
    }

    public String getPdfPath() {
        return pdfPath;
    }

    public void setPdfPath(String pdfPath) {
        this.pdfPath = pdfPath;
    }

    public String getTxtPath() {
        return txtPath;
    }

    public void setTxtPath(String txtPath) {
        this.txtPath = txtPath;
    }

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name = "stdref", joinColumns = {
            @JoinColumn(name = "source", nullable = false, updatable = false)},
            inverseJoinColumns = {@JoinColumn(name = "target",
                    nullable = false, updatable = false)})
    public List<Standard> getRefStds() {
        return refStds;
    }

    public void setRefStds(List<Standard> refStds) {
        this.refStds = refStds;
    }

    public String getTextOcr() {
        return textOcr;
    }

    public void setTextOcr(String textOcr) {
        this.textOcr = textOcr;
    }

    @Transient
    public String getSearchFields() {
        return searchFields;
    }

    public void setSearchFields(String searchFields) {
        this.searchFields = searchFields;
    }

    public String getQuotas() {
        return quotas;
    }

    public void setQuotas(String quotas) {
        this.quotas = quotas;
    }

    @Override
    public String toString() {
        return "Standard{" +
                "name='" + name + '\'' +
                ", titleCn='" + titleCn + '\'' +
                ", titleEn='" + titleEn + '\'' +
                ", catCn='" + catCn + '\'' +
                ", catIcs='" + catIcs + '\'' +
                ", catStd='" + catStd + '\'' +
                ", publishDate=" + publishDate +
                ", effectiveDate=" + effectiveDate +
                ", language='" + language + '\'' +
                ", qicao='" + qicao + '\'' +
                ", guikou='" + guikou + '\'' +
                ", reference='" + reference + '\'' +
                ", workField='" + workField + '\'' +
                ", pdfPath='" + pdfPath + '\'' +
                ", txtPath='" + txtPath + '\'' +
                ", refStds=" + refStds +
                ", textOcr='" + textOcr + '\'' +
                ", valid=" + valid +
                ", searchFields='" + searchFields + '\'' +
                ", quotas='" + quotas + '\'' +
                '}';
    }
}
